package com.ruoyi.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseDomain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;
import java.util.List;

/**
 * 公共用户对象 com_user
 *
 * @author sunye
 * @date 2024-09-26
 */
@Data
public class ComUser extends BaseDomain
{
    private static final long serialVersionUID = 1L;

    @TableId(value ="user_id", type = IdType.AUTO)
    private Long userId;


    @TableField(exist = false)
    private Long isAdmin;


    @Excel(name = "用户账号")
    private String userName;

    @Excel(name = "姓名")
    private String realName;

    @Excel(name = "密码")
    private String password;

    private String delFlag;

    private Date loginDate;


    @TableField(exist = false)
    private Long[] roleIds;


    /** 角色对象 */
    private List<SysRole> roles;

    /** 岗位组 */
    private Long[] postIds;

    /** 角色ID */
    private Long roleId;

    @TableField(exist = false)
    private Long departmentId;

    @TableField(exist = false)
    private String departmentName;

    @Excel(name = "帐号状态")
    @TableField(exist = false)
    private String status;

    /** 创建者 */
    private String createBy;
    /** 更新者 */
    private String updateBy;

    @TableField(exist = false)
    //机构名称
    private String deptName;

    //是否有多个机构
    @TableField(exist = false)
    private Boolean  isMultipleDept;

//    public boolean isAdmin()
//    {
//        return isAdmin(this.isAdmin);
//    }

//    public static boolean isAdmin(Long isAdmin)
//    {
//        return isAdmin != null && 1L == isAdmin;
//    }

    //是否有多个小程序
    @TableField(exist = false)
    private Boolean  isMultipleSmall;

    //小程序Id
    @TableField(exist = false)
    private Long  smallId;

    //小程序类型
    @TableField(exist = false)
    private String type;

    //小程序名称
    @TableField(exist = false)
    private String smallName;



    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("userId", getUserId())
            .append("userName", getUserName())
            .append("realName", getRealName())
            .append("password", getPassword())
            .append("delFlag", getDelFlag())
            .append("loginDate", getLoginDate())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}
